<template>
    <j-modal :title="title" :width="width" :visible="visible" switchFullscreen @ok="handleOk" @cancel="handleCancel"
        cancelText="关闭">
        <a-form-model ref="form" :model="model">
            <a-row class="my-row">
                <a-col :span="24" v-for="(item, index) in model.hcSiteCommissionsList">
                    <a-form-model-item :label="item.merchantName" :labelCol="labelCol" :wrapperCol="wrapperCol">
                        <a-input-number v-model="item.amount" placeholder="佣金金额" />
                        元
                        <a-input-number v-model="item.percentage" placeholder="佣金百分比"
                            style="margin-left: 10px; width: 100px;" />
                        %
                    </a-form-model-item>
                </a-col>
            </a-row>
        </a-form-model>
    </j-modal>
</template>

<script>
import { httpAction, getAction, postAction } from '@/api/manage'

export default {
    components: {},
    data() {
        return {
            labelCol: {
                xs: { span: 24 },
                sm: { span: 5 },
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 16 },
            },
            title: '佣金编辑',
            width: 1200,
            visible: false,
            model: '',
        }
    },
    methods: {
        edit(record) {
            console.log('record', record);
            this.visible = true;
            this.model = JSON.parse(JSON.stringify(record));
            this.visible = true;
            console.log('model', this.model);
        },
        async handleOk() {
            let res = await postAction('hc/hcSite/editSiteCommission', this.model);
            console.log('res', res);
            if (res.success) {
                this.$message.success('设置成功');
                this.$emit('loadData');
                this.visible = false;
            } else {
                this.$message.success(res.message);
            }
        },
        handleCancel() {
            this.model = {};
            this.visible = false;
        }
    }
}
</script>
<style lang="scss"></style>